/**
 * 2018年12月6日上午7:04:29
 * @author 谢进财
 */
package com.baihang.platform.shiro;

import java.util.List;

import com.baihang.platform.model.UserModel;

/**
 * @author 身份 权限 验证服务类
 *
 */
public class SystemAuthorizingService {
	private SystemAuthorizingDao dao;
	
	public void setDao(SystemAuthorizingDao dao) {
		this.dao = dao;
	}

	public UserModel getUserModel(String userName,String password) {
		System.err.println("password="+password);
		UserModel model =dao.getUserModel(userName, password);		
		return model;
	}
	
	public UserModel getUserModel(String userName) {
		UserModel model =dao.getUserModel(userName);		
		return model;
	}
	
	public List<String> getRoleCodeList(String userCode){
		List<String> roleCodeList = dao.queryForListByString(String.format("select roleCode from system_userrole where userCode='%s' ", userCode));
		System.err.println(roleCodeList.get(0));
		return roleCodeList;
	}
	
	public List<String> getRoleAuthzList(String userCode){
		List<String> roleAuthzList = dao.queryForListByString(String.format("select permissionCode from system_roleauthz where roleCode in (select roleCode from system_userrole where userCode='%s')", userCode));
		System.err.println(roleAuthzList.get(0));
		return roleAuthzList;
	}
}
